package com.demo.controller;

import com.demo.entity.RoleMenu;
import com.demo.model.JsonMessage;
import com.demo.service.RoleMenuService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@Api(value = "角色目录接口")
@RequestMapping("/user/rolemenu")
public class RoleMenuController {
    @Autowired
    private RoleMenuService roleMenuService;

    @ApiOperation(value = "删除角色目录")
    @PostMapping("delete")
    @ResponseBody
    public JsonMessage delete(String RoleId) {
        JsonMessage message = new JsonMessage();
        roleMenuService.Delete(RoleId);
        return message;
    }

    @ApiOperation(value = "角色目录列表")
    @PostMapping("list")
    @ResponseBody
    public JsonMessage list(@RequestParam(defaultValue = "0") int pageIndex,
                            @RequestParam(defaultValue = "10") int pageSize) {
        JsonMessage message = new JsonMessage();
        PageInfo<RoleMenu> page = roleMenuService.list(pageIndex, pageSize);
        message.setData(page);
        return message;
    }

    @ApiOperation(value = "添加角色目录")
    @PostMapping("add")
    @ResponseBody
    public JsonMessage add(@RequestBody RoleMenu roleMenu) {
        JsonMessage message = new JsonMessage();
        roleMenuService.Insert(roleMenu);
        return message;
    }




}
